package controle;

import java.util.ArrayList;
import java.util.Date;
import java.util.Iterator;

import javax.swing.DefaultListModel;

import modelo.Aluguel;
import modelo.Veiculo;
import banco.BDAluguel;


public class AluguelController {
    
    Aluguel aluguel = new Aluguel();
    
    @SuppressWarnings({ "unchecked", "rawtypes" })
	public DefaultListModel preencherVeiculosAluguel(){
        
        DefaultListModel veiculosAlugaveis = new DefaultListModel();
        
        ArrayList<Veiculo> listaAlugaveis = new ArrayList<Veiculo>();
        listaAlugaveis = aluguel.selectAll();
        
        for (Iterator iterator = listaAlugaveis.iterator(); iterator.hasNext();) {
            Veiculo v = (Veiculo) iterator.next(); 
            veiculosAlugaveis.addElement(v.getModelo());
        }  
        
        return veiculosAlugaveis;
        
    }
    
    public void inserirDadosDoVeiculo(String placa, Date datainicio, Date datafim){
    	BDAluguel bdaluguel = new BDAluguel();
    	bdaluguel.inserirDadosDoVeiculoBanco(placa, datainicio, datafim);
    }

	public void setPeriodo(String placa, Date dataInicio, Date dataFim) {
		// TODO Auto-generated method stub
		Aluguel a = new Aluguel();
		BDAluguel bdaluguel = new BDAluguel();
		a.setDataInicio(dataInicio);
		a.setDataFim(dataFim);
		bdaluguel.setPeriodoBanco(placa, dataInicio, dataFim);
	}

	public void setCpf(String text) {
		// TODO Auto-generated method stub
		@SuppressWarnings("unused")
		BDAluguel bdaluguel = new BDAluguel();
		
	}

	public void novoAluguel(String placa, long cpf, Date dataInicio,
			Date dataFim, double valor) {
		// TODO Auto-generated method stub
		BDAluguel bda = new BDAluguel();
		Aluguel a = new Aluguel();
		a.setPlaca(placa);
		a.setCpf(cpf);
		a.setDataInicio(dataInicio);
		a.setDataFim(dataFim);
		a.setValor(valor);
		bda.insert(a);
		
	}
}
